#include<iostream>
#include<string>
#include<cstring>
using namespace std;
const int MAXN= 105;
int map[MAXN][MAXN];
bool vis[MAXN][MAXN];
int ma=0,ans=0,n,m;

void dfs(int x,int y){
	if(++ans > ma)	ma = ans;
	vis[x][y]=true;
	if(vis[x-1][y]==false && x-1>=1 && x-1<=n && y>=1 && y<=m && map[x-1][y] == 1){
		vis[x-1][y] = true;//左 
		dfs(x-1,y);
	}
	if(vis[x+1][y]==false && x+1>=1 && x+1<=n && y>=1 && y<=m && map[x+1][y] == 1){
		vis[x+1][y] = true;//右 
		dfs(x+1,y);
	}
	if(vis[x][y-1]==false && x>=1 && x<=n && y-1>=1 && y-1<=m && map[x][y-1] == 1){
		vis[x][y-1] = true;//上 
		dfs(x,y-1);
	}
	if(vis[x][y+1]==false && x>=1 && x<=n && y+1>=1 && y+1<=m && map[x][y+1] == 1){
		vis[x][y+1] = true;//下 
		dfs(x,y+1);
	}	
}

int main(){
	memset(map,0,sizeof map);
	memset(vis,0,sizeof vis);
	int k;
	cin>>n>>m>>k;
	int x,y;
	for(int i=1;i<=k;i++){
		cin>>x>>y;
		map[x][y] = 1;
	}
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(map[i][j] == 1 && vis[i][j] == false){
				ans = 0;
				dfs(i,j);
			}
		}
	}
	cout<<ma<<endl;
	return 0;
}
